SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for t_branch
-- ----------------------------
DROP TABLE IF EXISTS `t_branch`;
CREATE TABLE `t_branch` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `sn` varchar(50) DEFAULT NULL COMMENT '内部编码',
  `pid` int(11) DEFAULT NULL COMMENT '父级id',
  `code` varchar(40) NOT NULL COMMENT '机构代码',
  `name` varchar(40) NOT NULL COMMENT '名称',
  `full_name` varchar(40) NOT NULL COMMENT '全称',
  `type` varchar(10) NOT NULL COMMENT '类型',
  `leader` varchar(40) DEFAULT NULL COMMENT '负责人',
  `phone` varchar(40) DEFAULT NULL COMMENT '联系电话',
  `email` varchar(100) DEFAULT NULL COMMENT '电子邮箱',
  `fax` varchar(20) DEFAULT NULL COMMENT '传真',
  `address` varchar(100) DEFAULT NULL COMMENT '联系地址',
  `remark` varchar(255) DEFAULT NULL COMMENT '备注信息',
  `zipcode` varchar(40) DEFAULT NULL COMMENT '邮政编码',
  `sort_rank` int(11) DEFAULT NULL COMMENT '顺序',
  `is_del` tinyint(3) DEFAULT '0' COMMENT '是否删除',
  `enable` char(1) DEFAULT '1' COMMENT '启用/禁用',
  `update_time` datetime DEFAULT NULL COMMENT '最后更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `create_user` varchar(20) DEFAULT NULL COMMENT '创建用户',
  `update_user` varchar(20) DEFAULT NULL COMMENT '更改用户',
  `level` varchar(2) DEFAULT NULL COMMENT '树层级',
  PRIMARY KEY (`id`),
  UNIQUE KEY `indx_ancestors` (`sn`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COMMENT='组织机构';

-- ----------------------------
-- Records of t_branch
-- ----------------------------
BEGIN;
INSERT INTO `t_branch` (`id`, `sn`, `pid`, `code`, `name`, `full_name`, `type`, `leader`, `phone`, `email`, `fax`, `address`, `remark`, `zipcode`, `sort_rank`, `enable`, `update_time`, `create_time`, `create_user`, `update_user`, `level`) VALUES (1, '01', NULL, '01', 'EasyAdmin', 'EasyAdmin', '1', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, '1');
COMMIT;

-- ----------------------------
-- Table structure for t_config
-- ----------------------------
DROP TABLE IF EXISTS `t_config`;
CREATE TABLE `t_config` (
  `sn` varchar(50) NOT NULL COMMENT '编码',
  `value` varchar(300) DEFAULT NULL COMMENT '值',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统配置项';

-- ----------------------------
-- Records of t_config
-- ----------------------------
BEGIN;
INSERT INTO `t_config` (`sn`, `value`, `update_time`) VALUES ('PlatformConfig.CopyRight', '©2023 成都燃客物联网科技有限公司 版权所有', '2023-02-24 17:23:40');
INSERT INTO `t_config` (`sn`, `value`, `update_time`) VALUES ('PlatformConfig.LoginBgImg', 'https://api.qqsuu.cn/api/dm-bing', '2022-07-13 21:43:33');
INSERT INTO `t_config` (`sn`, `value`, `update_time`) VALUES ('PlatformConfig.LogoUrl', 'img/logo.png', '2022-03-21 16:03:57');
INSERT INTO `t_config` (`sn`, `value`, `update_time`) VALUES ('PlatformConfig.SystemName', 'EasyBoot', '2022-06-16 17:47:54');
COMMIT;

-- ----------------------------
-- Table structure for t_dictionary
-- ----------------------------
DROP TABLE IF EXISTS `t_dictionary`;
CREATE TABLE `t_dictionary` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '字典ID',
  `name` varchar(255) DEFAULT NULL COMMENT '名称',
  `rank` int(11) DEFAULT NULL COMMENT '排序',
  `sn` varchar(50) DEFAULT NULL COMMENT '编码',
  `type` varchar(50) DEFAULT NULL COMMENT '字典类型',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `is_fixed` tinyint(1) DEFAULT NULL COMMENT '是否为系统固定编码',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=98 DEFAULT CHARSET=utf8mb4 COMMENT='字典';

-- ----------------------------
-- Records of t_dictionary
-- ----------------------------
BEGIN;
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (1, '机构类型', 1, 'BranchType', 'dict', '2022-02-21 12:08:32', NULL);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (2, '类型1', 1, '1', 'BranchType', '2022-10-06 13:33:53', 0);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (3, '类型2', 2, '2', 'BranchType', '2022-10-06 13:34:49', 0);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (89, '权限范围', NULL, 'DataScope', 'dict', '2022-07-19 12:35:23', 1);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (90, '全部', 0, '1', 'DataScope', '2022-07-19 12:35:23', 1);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (91, '自定义', 1, '2', 'DataScope', '2022-07-19 12:35:23', 1);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (92, '本部门', 2, '3', 'DataScope', '2022-07-19 12:35:23', 1);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (93, '本部门及下级部门', 3, '4', 'DataScope', '2022-07-19 12:35:23', 1);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (94, '自己', 4, '5', 'DataScope', '2022-07-19 12:35:23', 1);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (95, '性别', NULL, 'Gender', 'dict', '2022-07-19 12:35:23', 1);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (96, '男', 0, 'M', 'Gender', '2022-07-19 12:35:23', 1);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (97, '女', 1, 'F', 'Gender', '2022-07-19 12:35:23', 1);
COMMIT;
-- ----------------------------
-- Table structure for t_multi_dictionary
-- ----------------------------
DROP TABLE IF EXISTS `t_multi_dictionary`;
CREATE TABLE `t_multi_dictionary` (
  `sn` varchar(100) NOT NULL COMMENT '编码',
  `parent_sn` varchar(100) NOT NULL COMMENT '父级编码',
  `rank` int(11) NOT NULL COMMENT '层级',
  `name` varchar(255) DEFAULT NULL COMMENT '名称',
  `code` varchar(10) DEFAULT NULL COMMENT '自定义编码',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `icon` varchar(255) DEFAULT NULL COMMENT '图标',
  `props` text COMMENT '附加属性',
  PRIMARY KEY (`sn`),
  KEY `idx_parent_sn` (`parent_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='多级字典';

-- ----------------------------
-- Table structure for t_job_info
-- ----------------------------
DROP TABLE IF EXISTS `t_job_info`;
CREATE TABLE `t_job_info` (
  `id` varchar(50) NOT NULL,
  `title` varchar(50) DEFAULT NULL COMMENT '标题',
  `cron` varchar(50) DEFAULT NULL COMMENT 'cron表达式',
  `memo` varchar(255) DEFAULT NULL COMMENT '说明',
  `last_time` datetime DEFAULT NULL COMMENT '最后一次执行时间',
  `next_time` datetime DEFAULT NULL COMMENT '下一次执行时间',
  `enable` tinyint(4) DEFAULT '1' COMMENT '是否可用',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='定时任务信息';

-- ----------------------------
-- Records of t_job_info
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for t_job_log
-- ----------------------------
DROP TABLE IF EXISTS `t_job_log`;
CREATE TABLE `t_job_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `task_id` varchar(50) NOT NULL COMMENT '任务ID',
  `execute_time` datetime DEFAULT NULL COMMENT '执行时间',
  `take_time` mediumtext COMMENT '执行时长（毫秒）',
  `status` varchar(5) DEFAULT NULL COMMENT '状态',
  `error_info` varchar(100) DEFAULT NULL COMMENT '错误信息',
  `ip` varchar(30) DEFAULT NULL COMMENT '执行任务的IP',
  `server_id` varchar(20) DEFAULT NULL COMMENT '服务ID',
  `user_name` varchar(50) DEFAULT NULL COMMENT '执行用户',
  PRIMARY KEY (`id`),
  KEY `idx_task_id` (`task_id`)
) ENGINE=InnoDB AUTO_INCREMENT=348 DEFAULT CHARSET=utf8mb4 COMMENT='定时任务执行日志';

-- ----------------------------
-- Records of t_job_log
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for t_operation_log
-- ----------------------------
DROP TABLE IF EXISTS `t_operation_log`;
CREATE TABLE `t_operation_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `module` varchar(20) DEFAULT NULL COMMENT '所属模块',
  `operate` varchar(50) DEFAULT NULL COMMENT '操作',
  `operate_type` varchar(10) DEFAULT NULL COMMENT '操作类型',
  `user_name` varchar(50) DEFAULT NULL COMMENT '用户',
  `user_type` varchar(10) DEFAULT NULL COMMENT '用户类型',
  `ip` varchar(30) DEFAULT NULL COMMENT '用户地址',
  `path` varchar(100) DEFAULT NULL COMMENT '请求地址',
  `query` varchar(100) DEFAULT NULL COMMENT '请求参数',
  `body` text COMMENT '请求内容',
  `status` varchar(10) DEFAULT NULL COMMENT '状态',
  `create_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COMMENT='用户操作日志';

-- ----------------------------
-- Records of t_operation_log
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for t_role
-- ----------------------------
DROP TABLE IF EXISTS `t_role`;
CREATE TABLE `t_role` (
  `sn` varchar(20) NOT NULL COMMENT '编码',
  `name` varchar(20) DEFAULT NULL COMMENT '角色名',
  `role_type` varchar(20) DEFAULT NULL COMMENT '角色类型',
  `scope` varchar(20) DEFAULT NULL COMMENT '权限范围',
  PRIMARY KEY (`sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统角色';

-- ----------------------------
-- Records of t_role
-- ----------------------------
BEGIN;
INSERT INTO `t_role` (`sn`, `name`, `role_type`, `scope`) VALUES ('admin', '系统管理员', NULL, '1');
INSERT INTO `t_role` (`sn`, `name`, `role_type`, `scope`) VALUES ('user', '用户', NULL, '4');
COMMIT;

-- ----------------------------
-- Table structure for t_role_permission
-- ----------------------------
DROP TABLE IF EXISTS `t_role_permission`;
CREATE TABLE `t_role_permission` (
  `role` varchar(20) NOT NULL,
  `permission` varchar(20) NOT NULL,
  PRIMARY KEY (`role`,`permission`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色权限';

-- ----------------------------
-- Records of t_role_permission
-- ----------------------------
BEGIN;
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.branch');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.config');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.dictionary');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.role');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.user');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.user.add');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.user.delete');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.user.edit');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'Home');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.branch');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.config');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.dictionary');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.role');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.user');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.user.add');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.user.delete');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.user.edit');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'WORKS');
COMMIT;

-- ----------------------------
-- Table structure for t_slow_sql_log
-- ----------------------------
DROP TABLE IF EXISTS `t_slow_sql_log`;
CREATE TABLE `t_slow_sql_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `log_sql` varchar(255) DEFAULT NULL COMMENT '调用SQL语句',
  `take_time` int(11) DEFAULT NULL COMMENT '执行时长（毫秒）',
  `log_time` timestamp NULL DEFAULT NULL COMMENT '执行记录时间',
  `code_trace` varchar(255) DEFAULT NULL COMMENT '代码位置跟踪',
  `over_time_count` int(11) DEFAULT NULL COMMENT '超时次数',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='慢SQL记录日志';

-- ----------------------------
-- Records of t_slow_sql_log
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for t_user
-- ----------------------------
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `username` varchar(40) NOT NULL COMMENT '用户名',
  `password` varchar(128) NOT NULL COMMENT '密码',
  `user_type` char(1) DEFAULT NULL COMMENT '用户类型',
  `name` varchar(20) DEFAULT NULL COMMENT '姓名',
  `branch_sn` varchar(20) DEFAULT NULL COMMENT '部门编码',
  `avatar` varchar(255) DEFAULT NULL COMMENT '头像',
  `phone` varchar(40) DEFAULT NULL COMMENT '手机号',
  `enable` tinyint(1) DEFAULT '0' COMMENT '启用',
  `gender` varchar(1) DEFAULT '0' COMMENT '性别',
  `props` varchar(500) DEFAULT NULL COMMENT '附加属性',
  `create_user` varchar(40) DEFAULT NULL COMMENT '创建人',
  `login_ip` varchar(255) DEFAULT NULL COMMENT '最后登录IP',
  `login_time` datetime DEFAULT NULL COMMENT '最后登录时间',
  `create_time` datetime DEFAULT NULL COMMENT '记录创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_username` (`username`) USING BTREE,
  KEY `idx_branch_sn` (`branch_sn`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='平台用户';

-- ----------------------------
-- Records of t_user
-- ----------------------------
BEGIN;
INSERT INTO `t_user` (`id`, `username`, `password`, `user_type`, `name`, `branch_sn`, `avatar`, `phone`, `enable`, `gender`, `create_user`, `login_ip`, `login_time`, `create_time`, `update_time`) VALUES (1, 'admin', '0ee0a1f62b6d583937a2897b5f720f49', 'U', '超级管理员', '01', NULL, '13567897656', 1, 'M', NULL, NULL, NULL, NULL, NULL);
COMMIT;

-- ----------------------------
-- Table structure for t_user_role
-- ----------------------------
DROP TABLE IF EXISTS `t_user_role`;
CREATE TABLE `t_user_role` (
  `user_name` varchar(20) NOT NULL COMMENT '用户名',
  `role` varchar(20) NOT NULL,
  PRIMARY KEY (`user_name`,`role`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户角色';

-- ----------------------------
-- Records of t_user_role
-- ----------------------------
BEGIN;
INSERT INTO `t_user_role` (`user_name`, `role`) VALUES ('admin', 'admin');
COMMIT;
-- ----------------------------
-- Table structure for t_user_wx
-- ----------------------------
CREATE TABLE  IF NOT EXISTS  `t_user_wx`  (
   `user_id` int NOT NULL COMMENT '用户ID',
   `union_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'UnionID',
   `openid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'openID',
   PRIMARY KEY (`user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信用户' ROW_FORMAT = Dynamic;


-- ----------------------------
-- 流水号
-- ----------------------------
CREATE TABLE  IF NOT EXISTS  `t_max_no`  (
    `no_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
    `no_value` bigint(20) NULL DEFAULT NULL,
    PRIMARY KEY (`no_name`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '最大编号' ROW_FORMAT = Dynamic;

-- ----------------------------
-- 编码规则
-- ----------------------------
CREATE TABLE  IF NOT EXISTS  `t_codes`  (
     `id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID',
     `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '编码名称',
     `memo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
     `rules` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '规则',
     `add_time` datetime NULL DEFAULT NULL COMMENT '添加时间',
     `add_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '添加人',
     `modify_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
     `modify_user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改人',
     PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '编码规则' ROW_FORMAT = Dynamic;


SET FOREIGN_KEY_CHECKS = 1;
